﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Messaging;

namespace Sinacor.OMM.ConnectionManager.ErrorHandlers
{
    public class MsmqCanNotRead : IErrorHandler
    {
        #region IErrorHandleStrategy Members

        public string HandleError(PSE.Framework.Messaging.Msmq msmq, Exception exception)
        {
            StringBuilder error = new StringBuilder();
            MessageQueueException messageQueueException = (MessageQueueException)exception;
            
            error.AppendFormat("Impossível ler a fila............: [{0}] {1}", msmq.Path, Environment.NewLine);
            error.AppendFormat("Exception Message................: [{0}] {1}", messageQueueException.Message, Environment.NewLine);
            error.AppendFormat("Exception MessageQueueErrorCode..: [{0}] {1}", messageQueueException.MessageQueueErrorCode, Environment.NewLine);
            error.AppendFormat("Exception ErrorCode..............: [{0}] {1}", messageQueueException.ErrorCode, Environment.NewLine);
            error.AppendFormat("Exception StackTrace.............: [ {0} ", messageQueueException.StackTrace);

            return error.ToString();
        }

        #endregion
    }
}
